package Demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2024-05-23
 * Time: 12:57
 */
public class Animal {
    protected String name;
    protected int age;

    static {
        System.out.println("Animal的静态代码块");
    }
    {
        System.out.println("Animal的实例化代码块");
    }

    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
        System.out.println("Animal的构造函数Animal()");

    }

    public String toString() {
        return "{ 姓名：" + name +
                " 年龄：" + age + " }" ;
    }
    protected void eat() {
        System.out.println(name + "吃东西");
    }
}
